/**
  ******************************************************************************
  * @file    key.h
  * @author  杨启坤
  * @version V0
  * @date    2024-11-23
  * @brief  对于按键的封装        （按下低电平）
  * *               key1 引脚 PA0
                    key2 引脚 PE2
                    key3 引脚 PE3
                    key4 引脚 PE4
  *
  ******************************************************************************
  * @attention
  *  注意：
  *
  *
  ******************************************************************************
  */
/* Includes ------------------------------------------------------------------*/
#include "key.h"
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Private functions ---------------------------------------------------------*/

void KEY_Init(void)
{
    //定义GPIO结构体
    GPIO_InitTypeDef GPIO_Key1;
    GPIO_InitTypeDef GPIO_Key2;
    //使能GPIO时钟使能
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOA, ENABLE);
    RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE);
    //配置GPIO
    GPIO_Key1.GPIO_Pin = GPIO_Pin_0;
    GPIO_Key1.GPIO_Mode = GPIO_Mode_IN;
    GPIO_Key1.GPIO_PuPd = GPIO_PuPd_NOPULL;
    //配置GPIO
    GPIO_Key2.GPIO_Pin = GPIO_Pin_2 | GPIO_Pin_3 | GPIO_Pin_4;
    GPIO_Key2.GPIO_Mode = GPIO_Mode_IN;
    GPIO_Key2.GPIO_PuPd = GPIO_PuPd_NOPULL;
    //初始化GPIO
    GPIO_Init(GPIOA, &GPIO_Key1);
    GPIO_Init(GPIOE, &GPIO_Key2);
}



/************************ (C) COPYRIGHT 2024 杨启坤 *****END OF FILE****/





